package com.gao.udp;

import java.io.IOException;
import java.net.*;

/**
 * @Author: ShanYuqing
 * @Version: v1.0
 */
public class send {
    public static void main(String[] args) throws IOException {
        //1.创建DatagramSocket对象
        DatagramSocket datagramSocket = new DatagramSocket(8888);
        String msg = "如果让他陪你过冬天，我能不能睡中间";
         byte[] bytes = msg.getBytes();
         //2.创建DatagramPacket对象
        DatagramPacket packet = new DatagramPacket(bytes,bytes.length,
                InetAddress.getByName("127.0.0.1"),9999);
        //3.发送数据
        datagramSocket.send(packet);
        //4.释放资源
        datagramSocket.close();
    }
}
